package view;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JSeparator;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import model.FacturaView;

import controller.Sistema;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ConsultarDeuda extends javax.swing.JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JTextField dni;
	private JLabel dniLabel;
	private JTextArea jArea;
	private JButton jButton1;
	private JButton jSalir;
	private JSeparator jSeparator1;
	private JButton jBuscar;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				ConsultarDeuda inst = new ConsultarDeuda();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public ConsultarDeuda() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				dni = new JTextField();
				getContentPane().add(dni);
				dni.setBounds(78, 22, 123, 28);
			}
			{
				dniLabel = new JLabel();
				getContentPane().add(dniLabel);
				dniLabel.setText("DNI:");
				dniLabel.setBounds(22, 24, 50, 22);
			}
			{
				jBuscar = new JButton();
				getContentPane().add(jBuscar);
				jBuscar.setText("Buscar");
				jBuscar.setBounds(232, 20, 95, 31);
				
				jBuscar.addActionListener(new ActionListener() 
				{
					
					@Override
					public void actionPerformed(ActionEvent arg0) {
						Vector<FacturaView> fact = Sistema.getInstance().consultarDeudaUsuario( dni.getText());
							if  ( fact.size()<1){
								HelperTest.showMessage("Usuario sin deudas");
							}
							else
							{
								jArea.append("*************");
							}
							limpiarCampos();	
						
					}
				});
			}
			{
				jSeparator1 = new JSeparator();
				getContentPane().add(jSeparator1);
				jSeparator1.setBounds(12, 62, 361, 13);
			}
			{
				jArea = new JTextArea();
				getContentPane().add(jArea);
				getContentPane().add(getJButton1());
				jArea.setBounds(24, 75, 326, 167);
			}
			pack();
			this.setSize(400, 355);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private JButton getJSalir() {
		if(jSalir == null) {
			jSalir = new JButton();
			jSalir.setText("Salir");
		}
		return jSalir;
	}
	
	private JButton getJButton1() {
		if(jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setText("Salir");
			jButton1.setBounds(139, 272, 93, 23);
		}
		return jButton1;
	}
	private void limpiarCampos() {
		dni.setText("");
	}

}
